#include <iostream>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
 
using namespace std;
typedef long long ll;
const int N = 1005;
ll a[N];

ll gcd(ll x, ll y){
	if (!x || !y) return x > y ? x : y;
	for (int t; t = x % y; x = y, y = t);
	return y;
}
ll lcm(ll x, ll y){
	return x * y / gcd(x, y);
}
 
int main() {
    int t, n, flag;
    scanf("%d", &t);
    while(t--){
		scanf("%d", &n);
		
		for(int i=0;i<n;i++){
			scanf("%lld", &a[i]);
		}
		
		ll lcmnow = a[0];
		flag = 0;
		for(int i=1;i<n;i++){
			lcmnow = lcm(a[i], lcmnow);
			if(lcmnow > 1e9){
				flag = 1;
				break;
			}
		}
		if(flag){
			printf("-1\n");
		}else{
			printf("%lld\n", lcmnow);
		}
	}
    return 0;
}
